package cn.oms.commons.util;

import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;


public class StringToDate {
    public static LocalDateTime StrToDate(String DateStr) {
        String format = "yyyy/MM/dd HH:mm:ss";
        // 创建时间字符串的解析器
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
        LocalDateTime dateTime = LocalDateTime.parse(DateStr, formatter); // 解析时间字符串

        return dateTime;

    }

        public  static LocalDate convert(String dateString) {
            try {
                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                return LocalDate.parse(dateString, formatter);
            } catch (DateTimeParseException e) {
                e.printStackTrace();
                return null;
            }
        }
    }





